import Vue from 'vue'
import Router from 'vue-router'
import Root from '@/components/Root'
import Index from '@/components/pages/Index'
import Session from '@/components/pages/Session'
import History from '@/components/pages/History'
import Visitor from '@/components/pages/Visitor'
import Order from '@/components/pages/Order'
import Setting from '@/components/pages/Setting'
import Statistic from '@/components/pages/Statistic'
import Customer from '@/components/pages/Customer'
import OrderItem from '@/components/items/OrderItem'
import StatisticOverview from '@/components/items/StatisticOverview'
import StatisticWorkload from '@/components/items/StatisticWorkload'
import StatisticAttendance from '@/components/items/StatisticAttendance'
import StatisticPageview from '@/components/items/StatisticPageview'
import StatisticWorkquality from '@/components/items/StatisticWorkquality'
import SettingAnnouncement from '@/components/items/SettingAnnouncement'
import SettingAutoReply from '@/components/items/SettingAutoReply'
import SettingBasicSetting from '@/components/items/SettingBasicSetting'
import SettingBlacklist from '@/components/items/SettingBlacklist'
import SettingCommonWord from '@/components/items/SettingCommonWord'
import SettingCsManagement from '@/components/items/SettingCsManagement'
import SettingCustomerInfo from '@/components/items/SettingCustomerInfo'
import SettingCustomerTag from '@/components/items/SettingCustomerTag'
import SettingDialogRule from '@/components/items/SettingDialogRule'
import SettingDistributionRule from '@/components/items/SettingDistributionRule'
import SettingEnterpriceInfo from '@/components/items/SettingEnterpriceInfo'
import SettingGroupManagement from '@/components/items/SettingGroupManagement'
import SettingMessageNotification from '@/components/items/SettingMessageNotification'
import SettingOperationLog from '@/components/items/SettingOperationLog'
import SettingOrderClassification from '@/components/items/SettingOrderClassification'
import SettingProfile from '@/components/items/SettingProfile'
import SettingRoleManagement from '@/components/items/SettingRoleManagement'
import SettingSessionComment from '@/components/items/SettingSessionComment'
import CustomerDetail from '@/components/pages/CustomerDetail'
import Login from '@/components/Login'
import Register from '@/components/Register'
import Page404 from '@/components/Page404'
import OrderDetail from "@/components/pages/OrderDetail"
import SettingCsDetail from "@/components/items/SettingCsDetail";
import SettingRoleDetail from "@/components/items/SettingRoleDetail";
import VisitorSession from "../components/VisitorSession";

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/register', component: Register, meta: { title: '客服注册' } },
    { path: '/login', component: Login, meta: { title: '客服登录' } },
    { path: '/logout', redirect: '/login', meta: { title: '客服登录' } },
    { path: '/404', component: Page404, meta: { title: '404' } },
    {path: '/visitorSession',component: VisitorSession, meta: {title: '访客首页'}},
    {
      path: '/',
      component: Root,
      children: [
        {
          path: 'index',
          component: Index,
          meta: { title: '首页' }
        },
        {
          path: 'session',
          component: Session,
          meta: { title: '会话' }
        },
        {
          path: 'visitor',
          component: Visitor,
          meta: { title: '访客' }
        },
        {
          path: 'history',
          component: History,
          meta: { title: '历史会话' }
        },
        {
          path: 'customer',
          component: Customer,
          meta: { title: '客户' }
        },
        {
          path: 'customer/detail',
          component: CustomerDetail,
          name: 'customer-detail',
          meta: { title: '客户详情' }
        },
        {
          path: 'order',
          component: Order,
          redirect: '/order/all-order',
          children: [
            {
              path: 'all-order',
              component: OrderItem,
              meta: { title: '工单' }
            },
            {
              path: 'pendingOrder',
              component: OrderItem,
              meta: { title: '工单' }
            },
            {
              path: 'createdOrder',
              component: OrderItem,
              meta: { title: '工单' }
            },
            {
              path: 'sendedOrder',
              component: OrderItem,
              meta: { title: '工单' }
            },
            {
              path: 'handledOrder',
              component: OrderItem,
              meta: { title: '工单' }
            },
            {
              path: 'solvedOrder',
              component: OrderItem,
              meta: { title: '工单' }
            },
          ]
        },
        {
          path: 'order/detail',
          name: "order-detail",
          component: OrderDetail,
          meta: { title: '工单详情' }
        },
        {
          path: 'statistic',
          component: Statistic,
          redirect: '/statistic/overview',
          children: [
            {
              path: 'overview',
              component: StatisticOverview,
              meta: { title: '数据总览' }
            },
            {
              path: 'workload',
              component: StatisticWorkload,
              meta: { title: '工作量统计' }
            },
            {
              path: 'workquality',
              component: StatisticWorkquality,
              meta: { title: '工作质量统计' }
            },
            {
              path: 'attendance',
              component: StatisticAttendance,
              meta: { title: '考勤统计' }
            },
            {
              path: 'pageview',
              component: StatisticPageview,
              meta: { title: '访问统计' }
            }
          ]
        },
        {
          path: 'setting',
          component: Setting,
          redirect: '/setting/profile',
          children: [
            {
              path: 'profile',
              component: SettingProfile,
              meta: { title: '个人信息' }
            },
            {
              path: 'announcement',
              component: SettingAnnouncement,
              meta: { title: '通知公告' }
            },
            {
              path: 'enterprise-info',
              component: SettingEnterpriceInfo,
              meta: { title: '企业信息' }
            },
            {
              path: 'cs-management',
              component: SettingCsManagement,
              meta: { title: '客服管理' }
            },
            {
              path: 'cs-management-detail',
              component: SettingCsDetail,
              name: "cs-management-detail",
              meta: { title: '新增客服信息' }
            },
            {
              path: 'group-management',
              component: SettingGroupManagement,
              meta: { title: '分组管理' }
            },
            {
              path: 'role-management',
              component: SettingRoleManagement,
              meta: { title: '角色管理' }
            },
            {
              path: 'role-management-detail',
              component: SettingRoleDetail,
              name: "role-management-detail",
              meta: { title: '新增角色信息' }
            },
            {
              path: 'common-word',
              component: SettingCommonWord,
              meta: { title: '常用语' }
            },
            {
              path: 'auto-reply',
              component: SettingAutoReply,
              meta: { title: '自动回复' }
            },
            {
              path: 'dialog-rule',
              component: SettingDialogRule,
              meta: { title: '对话规则' }
            },
            {
              path: 'distribution-rule',
              component: SettingDistributionRule,
              meta: { title: '分配规则' }
            },
            {
              path: 'session-comment',
              component: SettingSessionComment,
              meta: { title: '会话评价' }
            },
            {
              path: 'customer-info',
              component: SettingCustomerInfo,
              meta: { title: '客户信息' }
            },
            {
              path: 'customer-tag',
              component: SettingCustomerTag,
              meta: { title: '客户标签' }
            },
            {
              path: 'blacklist',
              component: SettingBlacklist,
              meta: { title: '黑名单' }
            },
            {
              path: 'basic-setting',
              component: SettingBasicSetting,
              meta: { title: '基础设置' }
            },
            {
              path: 'order-classification',
              component: SettingOrderClassification,
              meta: { title: '工单分类' }
            },
            {
              path: 'operation-log',
              component: SettingOperationLog,
              meta: { title: '操作日志' }
            },
            {
              path: 'message-notification',
              component: SettingMessageNotification,
              meta: { title: '消息通知' }
            }
          ]
        },
      ]
    },
    {
      path: "*",
      redirect: "/404",
    }
  ]
})
